package com.atguigu.staservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author fxy
 * @since 2022-05-16
 */
@RestController
//@CrossOrigin
@RequestMapping("/staservice/sta")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    //统计某一天注册人数，生成统计数据加到数据库
    @GetMapping("/registerCount/{day}")
    public R registerCount(@PathVariable String day){
        statisticsDailyService.registerCount(day);
        return R.ok();
    }

    //图表显示,返回两部分数据，日期json数组，数量json数组
    @GetMapping("/shouData/{type}/{begin}/{end}")
    public R shouData(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        Map<String,Object> map = statisticsDailyService.getShouData(type,begin,end);

        return R.ok().data(map);
    }

    //显示全部数据图标显示
    @GetMapping("/showAllData/{begin}/{end}")
    public R showAllData(@PathVariable String begin,@PathVariable String end){
        Map<String,Object> map=statisticsDailyService.showAllData(begin,end);
        return R.ok().data(map);
    }

    //首页数据展示
    @GetMapping("/getAllData")
    public R getAllData(){
        Map<String,Object> map=statisticsDailyService.getAllData();
        return R.ok().data(map);
    }
}


